%%
%计算皮尔逊相关系数
%计算
data=readmatrix("副本附件(1)(2).xlsx","Sheet","合并表单","Range",'H2:T58');
epsilon = 1e-5;  % 例如，1e-5 或其他合适的值

% 将 epsilon 应用于矩阵 X，避免对数变换中的0值问题
X_offset = data + epsilon * max(data, [], 2);  % 按行添加 epsilon 乘以每行的最大值

fm=geomean(X_offset,2);
for i = 1:57
    for j = 1:13
        y(i,j) = log((X_offset(i,j))./(fm(i,1)));
    end
end
daba2=readmatrix("副本附件(1)(2).xlsx","Sheet","Sheet2","Range",'A21:N57');
r2 = corr(daba2);
%高钾的
daba = readmatrix("副本附件(1)(2).xlsx",'Sheet','Sheet2','Range','A1:N20');
r = corr(daba);
%disp(r);
y2=readmatrix("副本附件(1)(2).xlsx","Sheet","Sheet1","Range",'G2:T58');